<?php if(isset($notification)):?>
<b><?=$notification?></b>
<?php else:?>

<script type="text/javascript">

    window.addEvent('domready', function() {

        $('editewidget').addEvent('submit', function(e) {
            
            e.stop();
            $('ajax-loader').removeClass('hide');
            
            this.set('send', {
                url : '<?=current_url()?>',
                onComplete: function(response) {

                	$('form_error').set('html', response);
                	ajax_url('<?=modul_url('widgets', true)?>', 'main_content');
                }
            });
            
            this.send();
        });

        var options_slide = function() {

        	if ($('cache_options_slide').checked) {

        		$('cache_options').setStyle('display', 'block');
        	}
        	else {

        		$('cache_options').setStyle('display', 'none');
        	}
        }

        options_slide();
        $('cache_options_slide').addEvent('click', options_slide);

    });

  //Tabs
    new SimpleTabs($('tab'), {selector: 'h4'});
    
</script>

<?=form_open(current_url(), array('class' => 'hform', 'id' => 'editewidget'), array('edit' => true));?>

<span id="form_error"></span>

<div id="tab">
    <h4>Основные</h4>
    <div>
        <p>
            <label><?=lang('widget_field_container')?></label>
            <?=form_dropdown('container', $containers, $widget['container'])?>
        </p>
        <p>
            <label><?=lang('widget_field_title')?></label>
            <?=form_input('title', $widget['title'])?>
        </p>
        <p>
            <label><?=lang('widget_field_order')?></label>
            <?=form_input('order', $widget['order'])?>
        </p>
    </div>
    
    <h4>Параметры</h4>
    <div>
        <p>
            <?=modules::run('admin/widgets/params', $widget['modul'], $widget['method'], $widget['parametrs'])?>
        </p>
    </div>
    
    <h4>Кэширование</h4>
    <div>
        <p>
            <label><?=lang('widget_cache_enable')?></label>
            <?=form_checkbox('cache_enable', 1, $cache['enable'], 'id="cache_options_slide"')?>
        </p>
        
        <span id="cache_options" style="display: none;">
        <b><?=lang('widget_cache_option')?></b>
        <p>
            <label><?=lang('widget_cache_usergroup')?></label>
            <?=form_checkbox('cache[usergroup]', 1, (isset($cache['usergroup'])) ? $cache['usergroup'] : false)?>
        </p>
        <p>
            <label><?=lang('widget_cache_userid')?></label>
            <?=form_checkbox('cache[userid]', 1, (isset($cache['userid'])) ? $cache['userid'] : false)?>
        </p>
        <p>
            <label><?=lang('widget_cache_segment')?></label>
            <?=form_input('cache[segment]', (isset($cache['segment']) && $cache['segment']) ? $cache['segment'] : 0)?>
        </p>
        <p>
            <label><?=lang('widget_cache_reload')?></label>
            <?=form_input('cache[reload]', (isset($cache['reload']) && $cache['reload']) ? $cache['reload'] : 0)?>
        </p>
        </span>
    </div>
</div>
<?=form_submit('edit', lang('save'));?> <?=form_reset('reset', lang('reset'));?>

</form>
<?php endif;?>